<?php
/* 
 * class.special.php
 * 我的城市首页-商家信息
 * @author samuel
 * @date 2009-05-23
 */
include_once 'class.mycityBase.php';
class mycity_special extends mycityBase {
    private $seller_id;
    private $step;


    function  __construct($core) {
        parent::__construct();
        //参数处理
	    $this->step = $this->params['step'] ? strtolower(trim($core->params['step'])) : 'index';
	    $this->seller_id = $this->params['sid'] ? (int)$this->params['sid'] : 0;
	    $this->user_id = $this->params['uid'] ? (int)$this->params['uid'] : 1;
	    $this->page = $this->params['page'] ? (int)$this->params['page'] : 1;
	    if(!$this->user_id){
		    $this->error = "用户ID不合法！";
		    $this->jumpError();
		    exit;
	    }
	    if(!$this->seller_id){
		    $this->error = "商家ID不合法！";
		    $this->jumpError();
		    exit;
	    }

        $run = "run_" . $this->step;
        
        //header("Content-type: text/vnd.wap.wml");
        $this->$run();
    }

    
    function run_index(){
        $page_title = "我的城市-商家特色";
	    $content = "";
	    $content .= "<a href='".$_SERVER['PHP_SELF']."?act=sellerinfo&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."' alt='返回上级'>返回上级</a><br/>";
	    //获取商家信息
	    $sellerBase = $this->core->load('seller::sellerBase');
	    $seller = $sellerBase->getSellerInfo($this->seller_id);
	    //获取评分人数
	    $grade_counts = $this->getSellerGrades($this->seller_id, '', true);
	    $content .= $seller['SellerNameCN'] . "(".$seller['SellerNo'].")<br/>";
	    $gradeIcons = $this->getSellerGradeIcon($seller['SellerGrade'], $grade_counts);
	    $content .= $gradeIcons."<br/>";
	    
	    $content .= "(已有".(int)$grade_counts."人评分)<br/>";
	    
	    //判断是否已经收藏过
	    $favor_tag = $this->core->load('myhome::myhomeBase')->getUserFavorites($this->user_id, $this->seller_id, true);
	    if(!$favor_tag){
	        $favor = "<a href='".$_SERVER['PHP_SELF']."?act=collect&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>收藏</a>|";
	    }
	    
	    //判断是否已经评分过
	    $grade_tag = $this->getSellerGrades($this->seller_id, $this->user_id, true);
	    if(!$grade_tag){
	        $grade = "<a href='".$_SERVER['PHP_SELF']."?act=grade&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>评分</a>|";
	    }
	
	    $content .= $favor.$grade."<a href='".$_SERVER['PHP_SELF']."?act=dfw&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>大富翁</a><br/>";
	    $content .= "<a href='".$_SERVER['PHP_SELF']."?act=sellerinfo&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>信息</a>|<a href='".$_SERVER['PHP_SELF']."?act=sellerinfo&amp;step=discount&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>优惠</a>|<a href='".$_SERVER['PHP_SELF']."?act=special&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>特色</a><br/>";
	    $content .= "<a href='".$_SERVER['PHP_SELF']."?act=opinion&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>评价</a>|<a href='".$_SERVER['PHP_SELF']."?act=parking&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>停车</a>|<a href='".$_SERVER['PHP_SELF']."?act=realenv&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."'>实景</a><br/><br/>";
	
	    //商家信息
	    $pagesize = 10;
	    $displaypage = 5;
	    $page = $this->page;
	    $current_url = $_SERVER['PHP_SELF']."?act=special&amp;uid=".$this->user_id."&amp;sid=".$this->seller_id;
	    $sql = "SELECT count(*) FROM `fun_seller_pic` WHERE 1 AND `SellerID`='".$this->seller_id."' AND `SellerPicClass`=1";
        $counts = $this->core->db->get_var($sql);
        $totalPages = ceil($counts/$pagesize);
        $pager = $this->core->utility->wap_pager($totalPages, $page, $displaypage, $current_url);
        $arr_limit = array('offset'=>($page-1)*$pagesize, 'pagesize'=>$pagesize, 'url'=>'');
	    $seller_spes = $this->getSellerPics($this->seller_id, 'spe', $arr_limit);
	    if($seller_spes){
	        foreach($seller_spes as $seller_spe){
	            $content .= "<img src='".$seller_spe['SellerPic']."' alt='".$seller_spe['SellerPic']."' /><br/>";
	            $content .= $seller_spe['SellerPic'] . "<br/>";
	        }
	    }
	    
	    
	    $content .= $pager."<br/><br/>";
	    
	    $content .= "<a href='".$_SERVER['PHP_SELF']."?act=sellerinfo&amp;sid=".$this->seller_id."&amp;uid=".$this->user_id."' alt='返回上级'>返回上级</a><br/>";
	    $content .= "<a href='' alt='建议帮助'>建议帮助</a>";



	    $this->core->tpl->assign('content', $content);
	    $this->core->tpl->assign('page_title', $page_title);
	    $this->core->tpl->display('comm.wml');
    }
}


?>
